<!--  -->
<template>
    <div>
        <van-nav-bar title="收货地址" left-text="返回" left-arrow />
        <van-address-edit
                :area-list="areaList"
                show-postal
                show-delete
                show-set-default
                show-search-result
                :search-result="searchResult"
                :area-columns-placeholder="['请选择', '请选择', '请选择']"
                @save="onSave"
                @delete="onDelete"
                @change-detail="onChangeDetail"
        />


    </div>
</template>

<script>
    import areaList from '../../../../assets/areaList';
    export default {
        name : 'AddressEdit',
        data() {
            return {

                searchResult: [],
                addressInfo:{},


            };
        },
        computed:{
            areaList(){
                return areaList;

            }
        },
        methods: {
            onSave(val) {
                //  console.log(val)
                this.addressInfo={
                    addressContent:val.province+val.city+val.county+val.addressDetail,
                    addressName:val.name,
                    addressPhone:val.tel,
                    isDefault:val.isDefault?1:0
                }
                console.log(this.addressInfo)
                let sess = JSON.parse(sessionStorage.getItem("user"))

                this.$axios.post('/api/address/add?userId='+sess.userId,this.addressInfo).then((res)=>{
                    console.log(res)
                }).catch(err=>{
                    console.log(err)
                })

            },
            onDelete() {
                console.log('delete');
            },
            onChangeDetail(){

            }

        }
    }
</script>

<style  scoped>

</style>
